<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>LB-Admin1.0</title>
        {include file="header"}
    </head>
    <body>
    <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body layui-table-body layui-table-main">
                            <form class="layui-form layui-card" method="post" autocomplete="off">
                                <div class="layui-card-body">                            
                                    <div class="layui-form-item">
                                        <label class="layui-form-label label-required-next">栏目级别</label>
                                        <div class="layui-input-block">
                                            <select name='parent_id' class='layui-select' lay-search>
                                                <option value='0'>顶级栏目</option>
                                                {foreach $menus as $menu}
                                                {eq name='menu.id' value='$parent_id|default=0'}
                                                <option selected value='{$menu.id}'>{$menu.name}</option>
                                                {else}
                                                <option value='{$menu.id}'>{$menu.name}</option>
                                                {/eq}
                                                {/foreach}
                                            </select>
                                            <p class="help-block">必选，请选择上级顶级分类（目前最多支持三级分类）</p>
                                        </div>
                                    </div>
                            
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">分类名称</label>
                                        <div class="layui-input-block">
                                            <input name="name" value='{$vo.name|default=""}' required placeholder="请输入名称" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">排序</label>
                                        <div class="layui-input-block">
                                            <input name="sort" placeholder="请输入排序数字" value="{$vo.sort|default='0'}" class="layui-input">                                           
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">状态</label>
                                        <div class="layui-input-block">
                                            <input type="checkbox" name="status" value="1"  lay-text="显示|隐藏" checked="" lay-skin="switch">
                                        </div>
                                    </div>
                                </div>
                            
                                <div class="hr-line-dashed"></div>
                                <div class="layui-form-item">
                                        <div class="layui-input-block">
                                    <input type="hidden" name="id" value="{$vo.id|default=''}">
                                    <button class="layui-btn" type='button' onclick="save()">保存数据</button>
                                    <button class="layui-btn layui-btn-danger" type='button' onclick="closelayer()">关闭</button>
                           
                            </div></div>
                            </form>
                            
</div>
<script>
    function closelayer()
    {
        parent.layer.closeAll();
    }
    function save()
    {        
        var formdata=$('form').serializeArray();
        console.log(formdata)
       
        $.post('{:url('categorymodify')}',formdata,function(res){
            console.log(res)
            if(res.code==1)
            {
                parent.layer.close();
                parent.location.reload();
                
            }
            layer.open('保存失败')
        })
    }
var url = location.href;
layui.use(['form'], function(){
  var form = layui.form;
  layui.form.render();  
});
$(function(){
   
})
</script>
</div></div></div></div>
{include file="footer"}